﻿#pragma once

namespace micro
{
namespace core
{

template<typename T>
class QSingleton
{
public:
    QSingleton() { }
    virtual ~QSingleton() { }

    static T * getInstance()
    {
        return instance;
    }

    static void newInstance()
    {
        if ( instance )
            delete instance;

        instance = new T();
    }

    static void deleteInstance()
    {
        if ( instance )
            delete instance;

        instance = nullptr;
    }


protected:
    static T * instance;
private:
    QSingleton( const QSingleton & );
    QSingleton & operator=( const QSingleton & );

};

template<class T>
T * QSingleton<T>::instance = nullptr;

} // namespace dcpp



}//micro